package com.example.quartz.trigger;


import com.example.quartz.entity.TriggerInfo;
import org.quartz.DateBuilder;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;

/**
 *
 */
public class MyTrigger {
    /**
     * 创建触发器
     */
    public static Trigger create1(TriggerInfo triggerInfo) {
        return TriggerBuilder.newTrigger()
                .withIdentity(triggerInfo.getTriggerName(), triggerInfo.getTriggerGroup())
                // 3分钟后开始
                .startAt(DateBuilder.futureDate(3, DateBuilder.IntervalUnit.SECOND))
                // 15分钟后结束
                .endAt(DateBuilder.futureDate(20, DateBuilder.IntervalUnit.SECOND))
                .withSchedule(SimpleScheduleBuilder
                        .simpleSchedule()
                        // 每次间隔3分钟
                        .withIntervalInSeconds(3)
                        // 重复5次
                        .withRepeatCount(5))
                .build();
    }
}
